/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_GPIO.c
 *
 *  Created on: 2022年6月22日
 *      Author: Casa XU
 */

#include "LOS_GPIO.h"
#include "LOS_MAX14830.h"

void LOS_GPIO_Init()
{
    gioInit();
    gioSetBit(gioPORTA, 0, 1);
    gioSetDirection(hetPORT2, 0xFFFFFFFF);
    //gioEnableNotification(gioPORTB, 0);
    gioSetBit(mibspiPORT1, PIN_CS1, 0);
    gioSetBit(gioPORTB, 2, 1);
    gioSetBit(gioPORTB, 3, 0);
    gioSetBit(gioPORTB, 4, 1);
    gioSetBit(gioPORTB, 5, 1);
    gioSetBit(hetPORT2, 9, 1);
    gioSetBit(hetPORT2, 10, 1);
    gioSetBit(hetPORT1, 6, 0);
}

void gioNotification(gioPORT_t *port, uint32 bit)
{
    uint8_t maxport = 0;
    uint8_t read = 0;
    if (port == gioPORTA)
    {

    }
    else if (port == gioPORTB)
    {
        if (bit == 0)
        {
            for (maxport = 0; maxport < 4; maxport++)
            {
                read = LOS_MAX14830_ReadRegister(LOS_MAX14830_NUM1, 0, MAX14830_ISR_REG);
                if ((read & 0x40) != 0)
                {
                    break;
                }
            }
            if (maxport == 0)
            {

            }
            else if (maxport == 2)
            {

            }
            else if (maxport == 3)
            {

            }
            else
            {
                return;
            }
        }
        else if (bit == 1)
        {

        }
    }
}
